package com.blog.log;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/**
 * 利用监听器初始化加载日志系统<br>
 * @deprecated 测试其他方法
 * @author Administrator
 *
 */
public class Log4jInit implements ServletContextListener{
	static Logger log = Logger.getLogger(Log4jInit.class);
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub
		log.info("经监听器获知，ServletContext对象已销毁");
		
	}

	public void contextInitialized(ServletContextEvent arg0) {
		String configFilename = null;
		try {
			configFilename = FinalProperty.getLog4jurl();
			PropertyConfigurator.configure(configFilename);
			log.info("日志初始化成功，配置文件地址为："+configFilename);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			 
			System.out.println("日志初始化失败。");
			 
		}finally{
		 
		}
	}
		
	
}
